﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CGE.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to Cognitive Generation Enterprises!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Services()
        {
            return View();
        }

        public ActionResult Contact()
        {
            return View();
        }

        public ActionResult Inbox()
        {
            List<Email> MyEmails = new List<Email>();
            MyEmails.Add(new Email { Id = 1, Subject = "Email 1", Content="Here is the content to the first email", Date = DateTime.Now, Read = true });
            MyEmails.Add(new Email { Id = 2, Subject = "Email 2", Content = "Here is the content to the second email", Date = DateTime.Now.AddDays(-11), Read = false });
            MyEmails.Add(new Email { Id = 3, Subject = "Email 3", Content = "Here is the content to the third email", Date = DateTime.Now.AddDays(-22), Read = false });
            ViewBag.Emails = MyEmails;
            return View();
        }

        public string MarkEmailRead(string Id)
        {
            // Do the work of updating the email using LINQ to set it's Read status to True
            return "Ok: " + Id;
        }


    }

    public class Email
    {
        public int Id { get; set; }
        public string Subject { get; set; }
        public string Content { get; set; }
        public DateTime Date { get; set; }
        public bool Read { get; set; }
    }
}
